package 搜索算法.广度优先搜索;

import java.util.Stack;

/**
 * 1. 问题描述
 *
 * 2. 算法分析
 *
 * 3. 代码实现
 */
@SuppressWarnings("all")
public class 镜像对称二叉树 {
    public static void main(String[] args) {
        Stack<Integer> stack = new Stack<>();
        StringBuilder temp = new StringBuilder();
        temp.reverse().toString();
    }

    // 递归实现
    public static boolean isSymmetric(TreeNode root) {
        return isMirror(root,root);
    }

    // 递归函数
    public static boolean isMirror(TreeNode left,TreeNode right) {
        if(left == null && right == null) {
            return true;
        }
        if(left == null || right == null) {
            return false;
        }
        return (left.val == right.val) && isMirror(left.left,right.right) && isMirror(left.right,right.left);
    }
}
